package main

import (
	"fmt"
	"math"
)
type ErrNegativeSqrt float64

func (e ErrNegativeSqrt) Error() string{
	return fmt.Sprintf("cannot Sqrt negative number: %v",float64(e))
}


func Sqrt(x float64) (float64, error) {
	if x>=0{
		return math.Sqrt(2),nil
	}else{
		return x,ErrNegativeSqrt(x)
	}
}

func main() {
	fmt.Println(Sqrt(2))
	fmt.Println(Sqrt(-2))//返回-2 和 ErrNegativeSqrt(-2) Println的时候调用Error()
}
